<template>
    <view class="content">
        <view class="now-item" v-for="(item, index) in list" :key="index" 
            @click="$gTo(`/pages/goods/goods-details?sId=1&sType=4&puId=${item.id}`)">
            <view class="u-rela">
                <image :src="item.image" class="now-item-img" v-if="item.image"></image>
                <view class="now-item-nums">
                    <view class="now-item-num">{{item.end_time}}截止</view>
                </view>
            </view>
            <view class="now-item-down">
                <view class="now-item-tit u-line-1">{{item.title}}</view>
                <view class="now-item-time u-line-1" v-if="item.describes">{{item.describes}}</view>
            </view>
        </view>
        
        <view style="height: 94rpx;padding-top: 30rpx;">
            <u-loadmore :status="status" v-if="status != 'loadmore'" />
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
            };
        },
        onShow() {
            this.page = 1
            this.list = []
            this.status = 'loadmore'
            this.getList()
        },
        onReachBottom() {
        	if(this.page == 1){return}
        	this.getList()
        },
        methods: {
            // 获取列表
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('company_publicize', {
            		user_token: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
            	}).then(ret => {
            		if (ret.success == 1000) {
            			if (ret.detail && ret.detail.publicize && ret.detail.publicize.length > 0) {
            				this.list = this.list.concat(ret.detail.publicize);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
    .content{
        padding: 20rpx;
    }
    .now-item{
        background-color: #fff;
        border-radius: 15rpx;
        margin-bottom: 20rpx;
    }
    .now-item-img{
        width: 710rpx;
        height: 279rpx;
        border-radius: 0 15rpx 0 0;
    }
    .now-item-nums{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        width: 710rpx;
        position: absolute;
        bottom: 0;
        left: 0;
    }
    .now-item-num{
        padding: 8rpx 25rpx;
        border-radius: 0 15rpx 0 0;
        background: rgba(254, 189, 22, .8);
        font-size: 24rpx;
        color: #000;
    }
    .now-item-down{
        padding: 30rpx 35rpx;
    }
    .now-item-tit{
        // width: 455rpx;
        // white-space: nowrap;
        // overflow: hidden;
        // text-overflow: ellipsis;
        font-size: 32rpx;
        font-weight: bold;
        padding-bottom: 10rpx;
    }
    .now-item-time{
        font-size: 26rpx;
        color: #848484;
    }
    .now-btn{
        font-size: 26rpx;
        color: #fff;
        padding: 13rpx 35rpx;
        border-radius: 10rpx;
        background: linear-gradient(to right, #a93537,#680608);
    }
    .now-btn2{
        background: #808080;
    }

</style>
